﻿package tests;
import flash.display.Shape;
import flash.events.Event;
import flash.Lib;
import fpc.controls.buttons.Button;
import fpc.FoolProofComponents;
import fpc.layouts.ExcessSpaceMode;
import fpc.layouts.FormLayout;
import fpc.containers.Container;
import fpc.layouts.FormLayoutMode;
import fpc.controls.text.Label;

class FormLayoutTest extends GenericTest
{
	public function new() 
	{
		super();
	}
	
	var _container:Container<FormLayout>;
	
	override function init()
	{		
		var container = new Container<FormLayout>();
		container.addTo(this);
		_container = container;
		
		var shape = new Shape();
		addChild(shape);
		
		var layout = new FormLayout();
		layout.autoSize = false;
		layout.graphics = shape.graphics;
		
		var button = new Button('Button 0');
		button.toggle = true;
		button.percentsHeight = 100;
		layout.addLabeled('Parametr 0', button);
		
		var button = new Button('Button 1');
		button.toggle = true;
		layout.addLabeled('Parametr 1', button);
		
		var button = new Button('Button 2');
		button.toggle = true;
		layout.addLabeled('Parametr 2', button);
		
		layout.addLabeled('Parametr 3', new Button('Button 3'));
		layout.addLabel('Caption 0');
		layout.addLabeled('Parametr 0', new Button('Button 4'));
		layout.addLabeled('Parametr 1', new Button('Button 5'));
		layout.addLabeled('Parametr 2', new Button('Button 6'));
		layout.addLabeled('Parametr 3', new Button('Button 7'));
		layout.addLabeled(new Button('Button 8'));
		layout.add(new Button('Button 9'));
		
		layout.setColSize(0, 200);
		layout.setRowPercents(0, 100);
		
		layout.formLayoutMode = FormLayoutMode.COMMON;
		
		container.layout = layout;
	}
	
	override function resize(width, height)
	{
		graphics.clear();
		
		_container.width = width;
		_container.height = height;
		
		if (_container.height > stage.stageHeight + .1)
		{
			graphics.beginFill(0x7ef000);
			graphics.drawRect(0, 0, _container.width, _container.height);
			graphics.endFill();
		}
	}
}